import static org.junit.Assert.*;
import java.awt.Point;

import javax.swing.JButton;


public class Test {
	Universe uni = new Universe();
	
	//Kushagra Mansingh
	@org.junit.Test
	public void testGenerateNewPoint1() {
		Point point = uni.generateNewPoint(0);
		assertTrue(point.equals(new Point(265, 142)));
	}
	
	@org.junit.Test
	public void testGenerateNewPoint2() {
		Point point = uni.generateNewPoint(0);
		Point other = uni.generateNewPoint(20);
		assertTrue(Math.ceil(other.distance(point))==20 || Math.floor(other.distance(point))==20);
	}
	
	@org.junit.Test
	public void testGenerateNewPoint3() {
		Point point = uni.generateNewPoint(0);
		Point other = uni.generateNewPoint(300);
		assertTrue(Math.ceil(other.distance(point))==300 || Math.floor(other.distance(point))==300);
	}
	
	@org.junit.Test
	public void testGenerateNewPoint4() {
		Point point = uni.generateNewPoint(0);
		Point other = uni.generateNewPoint(-20);
		assertTrue(Math.ceil(other.distance(point))==300 || Math.floor(other.distance(point))==300);
	}
	
	//Tyler LaBean
	@org.junit.Test
	public void testGenerateRadius() {
		
		Point p1;
		Point p2;
		Point p0 = uni.generateNewPoint(0);
		
		p2 = uni.assignPoints(0);
		p1 = p2;
		p2 = uni.assignPoints(1);
		assertTrue(p1.distanceSq(p0) > p2.distanceSq(p0));
	}
	
	@org.junit.Test
	public void testGenerateRadius1() {
		Point p1;
		Point p2;
		Point p0 = uni.generateNewPoint(0);
		
		p2 = uni.assignPoints(0);
		p1 = p2;
		p2 = uni.assignPoints(2);
		assertTrue(p1.distanceSq(p0) > p2.distanceSq(p0));
	}
	
	@org.junit.Test
	public void testGenerateRadius2() {
		
		Point p1;
		Point p2;
		Point p0 = uni.generateNewPoint(0);
		
		p2 = uni.assignPoints(0);
		p1 = p2;
		p2 = uni.assignPoints(3);
		assertTrue(p1.distanceSq(p0) > p2.distanceSq(p0));
	}
	
	//Sanat Moningi
	@org.junit.Test
	public void testAddItem(){
		Inventory backpack = new Inventory(100);
		Pair[] list = backpack.getInventory();
		//Test for Item 3
			//Should be empty
			assertTrue(list[3].getNumber()==0);
			//Add's one item
			backpack.addItem(Inventory.GOODLIST[3], 1);
			assertTrue(list[3].getNumber()==1);
			//Take item away
			backpack.addItem(Inventory.GOODLIST[3], -1);
			assertTrue(list[3].getNumber()==0);
			//Takes item away even when empty
			backpack.addItem(Inventory.GOODLIST[3], -1);
			list[3].getNumber();
			assertTrue(list[3].getNumber()<0);
			//Add's one item
			backpack.addItem(Inventory.GOODLIST[3], 1);
			assertTrue(list[3].getNumber()==0);
		//Test for fuel
			//Add 200 fuel
			backpack.addItem(Inventory.GOODLIST[0], 200);
			assertTrue(list[0].getNumber()==210);
			//Remove 210 fuel
			backpack.addItem(Inventory.GOODLIST[0], -210);
			assertTrue(list[0].getNumber()==0);
	}
	
	@org.junit.Test
	public void testReachable(){
		int [] skills=new int[4];
		skills[0]=4;
		skills[1]=4;
		skills[2]=4;
		skills[3]=4;
		Point p1=new Point(10,10);
		Point p2=new Point(10, 500);
		Player p=new Player(skills, "Badass", 1);
		SolarSystem system1 =new SolarSystem("hulu", 1, 1, 1, p1);
		SolarSystem system2 =new SolarSystem("netflix", 2, 2, 2, p2);
		p.setSystem(system1);
		JButton button= new JButton();
		UniverseMapController control=new UniverseMapController(p);
		control.reachable(button, system2);
		assertTrue(button.isEnabled());
		p.setFuel(100);
		control.reachable(button, system2);
		assertFalse(button.isEnabled());
	}
}
